<?php
require_once(dirname(__FILE__)."/../../libs/dbclass/dbconnect.php");
require_once(dirname(__FILE__)."/../../libs/string/libstr.php");
require_once(dirname(__FILE__)."/../../admin/libs/power_class.php");
$mc=new libstr();
$pw=new power();
$cataid=0;
if($_GET["id"]!=""){
$cataid=$_GET["id"];
}
$mid=$_GET["mid"]?$_GET["mid"]:0;
$parr=array();



//print_r($parr);
header("Content-Type:text/xml;");
echo '<?xml version="1.0" encoding="utf-8"'.'?'.'>';
echo '<tree id="0">';
echo '<item text="全部课程" id="" open="1" call="1" select="1" >';
echo getclass(0);
function getclass($cataid=0){
	
	global $db;
	global $mc;
	global $parr;
 $sql="select ID,classname,rootid,(select count(b.ID) as tt from product_class as b where b.pid=t.ID) as tj from product_class as t where t.pid=".$cataid." order by classorder asc  ";
 $getrs=$db->ds($sql);
 if(count($getrs)>0){
for($i=0;$i<count($getrs);$i++){
	if($getrs[$i][ID]==$_GET["cataid"]){
echo '<item text="'.$getrs[$i][classname].'" id="'.$getrs[$i][ID].'"  child="'.$getrs[$i]["tj"].'"  select="1" >';	
	}else{
	echo '<item text="'.$getrs[$i][classname].'" id="'.$getrs[$i][ID].'"  child="'.$getrs[$i]["tj"].'"  >';	
	}
getclass($getrs[$i][ID]);
}
 }
 echo '</item>';
}
echo '</tree>';
?>